﻿using CheatMenu.Managers;
using CheatMenu.Utils;
using Fungus;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace CheatMenu.Patch
{
    public class InstantWaitPatcher
    {
        public static bool Enabled { get; set; }

        public static void Patch(Harmony harmony)
        {
            BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;
            var original = typeof(Wait).GetMethod("OnEnter", bindingFlags);
            var prefix = typeof(InstantWaitPatcher).GetMethod("prefix_OnEnter");
            harmony.Patch(original, new HarmonyMethod(prefix), null);
        }

        public static void prefix_OnEnter(Wait __instance)
        {
            if (Enabled)
            {
                ReflectionUtil.SetWaitDuration(__instance, new FloatData(0f));
            }
        }
    }
}
